% Prepare environment
clc
clear
close all
addpath(genpath('../csrd'))

% Generate audio signal
source = blocks.physical.message.Audio(scale = 5);
x = source(10000, 0);

% Modulate x using DSBAM
ModulatorConfig.carramp = 1;
ModulatorConfig.initPhase = 0;
baseBandSignal = blocks.physical.modulate.analog.AM.DSBAM(ModulatorConfig = ModulatorConfig, ...
    NumTransmitAntennas = 1, ...
    SampleRate = x.SymbolRate);
x1 = baseBandSignal(x);
upConv1 = dsp.DigitalUpConverter( ...
    'InterpolationFactor', 5, ...
    'SampleRate', x1.SampleRate, ...
    'Bandwidth', max(abs(x1.BandWidth)) * 2, ...
    'StopbandAttenuation', 55, ...
    'PassbandRipple', 0.2, ...
    'CenterFrequency', 40e3);
y1 = upConv1(x1.data);

% Modulate x using DSBSCAM
ModulatorConfig.initPhase = 0;
baseBandSignal = blocks.physical.modulate.analog.AM.DSBSCAM(ModulatorConfig = ModulatorConfig, ...
    NumTransmitAntennas = 1, ...
    SampleRate = x.SymbolRate);
x2 = baseBandSignal(x);
upConv2 = dsp.DigitalUpConverter( ...
    'InterpolationFactor', 5, ...
    'SampleRate', x2.SampleRate, ...
    'Bandwidth', max(abs(x2.BandWidth)) * 2, ...
    'StopbandAttenuation', 55, ...
    'PassbandRipple', 0.2, ...
    'CenterFrequency', 40e3);
y2 = upConv2(x2.data);

% Modulate x using SSBAM
ModulatorConfig.mode = 'upper';
baseBandSignal = blocks.physical.modulate.analog.AM.SSBAM(ModulatorConfig = ModulatorConfig, ...
    NumTransmitAntennas = 1, ...
    SampleRate = x.SymbolRate);
x3 = baseBandSignal(x);
upConv3 = dsp.DigitalUpConverter( ...
    'InterpolationFactor', 5, ...
    'SampleRate', x3.SampleRate, ...
    'Bandwidth', max(abs(x3.BandWidth)) * 2, ...
    'StopbandAttenuation', 55, ...
    'PassbandRipple', 0.2, ...
    'CenterFrequency', 40e3);
y3 = upConv3(x3.data);

% Modulate x using VSBAM
ModulatorConfig.mode = 'upper';
ModulatorConfig.cutoff = 1e3;
baseBandSignal = blocks.physical.modulate.analog.AM.VSBAM(ModulatorConfig = ModulatorConfig, ...
    NumTransmitAntennas = 1, ...
    SampleRate = x.SymbolRate);
x4 = baseBandSignal(x);
upConv4 = dsp.DigitalUpConverter( ...
    'InterpolationFactor', 5, ...
    'SampleRate', x4.SampleRate, ...
    'Bandwidth', max(abs(x4.BandWidth)) * 2, ...
    'StopbandAttenuation', 55, ...
    'PassbandRipple', 0.2, ...
    'CenterFrequency', 40e3);
y4 = upConv4(x4.data);
